#!/bin/sh
################################################################################
# loopback
################################################################################
. /etc/rc.d/functions

start() {

    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/loopback] Starting..."

    # Bring up the loopback network interface.
    /sbin/ifconfig lo 127.0.0.1 up

    # Start portmap on the local netowrk interface.
    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/loopback] starting rpcbind on 127.0.0.1"
    /usr/bin/rpcbind

    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/loopback] Started with return code=0..."

    return 0
}

stop() {
    mm_message_output info "stoping loopback network interface ..."

    # Stop portmap on the local network interface.
    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/loopback] stoping rpcbind on 127.0.0.1"
    if [ -n "`/bin/pidof portmap`" ] ; then
        /usr/bin/killall portmap
    fi
    if [ -n "`/bin/pidof rpcbind`" ] ; then
        /usr/bin/killall rpcbind
    fi

    # Bring down the loopback network interface.
    /sbin/ifconfig lo 0 down

    return 0
}

case $1 in
    start) start ;;
    stop)  stop  ;;
esac

exit 0
